package com.wetao.testkotlin

sealed class TestSealed {
    class SealedNum(val value: Int):TestSealed()
    class  SealedSum(val left:TestSealed, val right: TestSealed):TestSealed()
}

fun eval(e:TestSealed):Int =
    when(e){
        is TestSealed.SealedNum -> e.value
        is TestSealed.SealedSum -> eval(e.right) + eval(e.left)
    }